package logic

import (
	"Junior_two/subject/goods/goodsrpc/model"
	"context"

	"Junior_two/subject/goods/goodsrpc/internal/svc"
	"Junior_two/subject/goods/goodsrpc/pb/goodRpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsListLogic {
	return &GoodsListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsListLogic) GoodsList(in *goodRpc.ListRequest) (*goodRpc.ListResponse, error) {
	// todo: add your logic here and delete this line
	total, showPage, nowPage, cuntPage, data := model.FenYe(in.Page, in.Name)
	return &goodRpc.ListResponse{
		Total:    total,
		ShowPage: showPage,
		NowPage:  nowPage,
		ConPage:  cuntPage,
		Data:     string(data),
	}, nil
}
